package n16.second;

import java.io.File;
import java.time.Instant;
import java.time.LocalDateTime;
import java.time.ZoneId;
import java.util.Arrays;
import java.util.Comparator;

public class S02 {

	public static void main(String[] args) {
		File dir = new File("D:\\");
		File[] files = dir.listFiles();
		Arrays.stream(files)
			//.sorted(Comparator.comparingLong(File::lastModified))
			.sorted(Comparator.<File>comparingInt(f->f.isDirectory()?0:1).thenComparingLong(File::lastModified))
			.forEach(f->{
				Instant ins = Instant.ofEpochMilli(f.lastModified());
				LocalDateTime dt = LocalDateTime.ofInstant(ins, ZoneId.of("PRC"));
				System.out.printf("%tF %<tT", dt );
				if(f.isDirectory()) System.out.print("  <DIR>                 ");
				else System.out.printf("%,22d  ", f.length());
				System.out.println(f.getName());
			});
	}

}
